package com.sevenGroup.pawnshop.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sevenGroup.pawnshop.controller.form.SelectWarehousesForm;
import com.sevenGroup.pawnshop.controller.form.WarehousesForm;
import com.sevenGroup.pawnshop.controller.form.pageForm;
import com.sevenGroup.pawnshop.controller.info.WarehousesInfo;
import com.sevenGroup.pawnshop.model.Warehouses;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author sevenGroup
 * @since 2022-02-16
 */
public interface WarehousesDao extends BaseMapper<Warehouses> {

    @Update("UPDATE warehouses SET warehouse_name=#{warehouseName}, warehouse_address=#{warehouseAddress}, warehouse_contact=#{warehouseContact}, warehouse_tel=#{warehouseTel}, warehouse_state=#{warehouseState} WHERE warehouse_id=#{warehouseId}")
    public void updateWarehouses(WarehousesForm warehousesForm);

    @Select("<script> select warehouse_id,warehouse_name,warehouse_address,warehouse_contact,warehouse_tel,warehouse_state from warehouses where 1=1" +
            "<if test =\"selectWarehousesForm.warehouseState!=''\"> " +
            "and warehouse_state=#{selectWarehousesForm.warehouseState} </if> " +
            "<if test =\"selectWarehousesForm.condition!=''\"> " +
            "and (warehouse_name LIKE    #{selectWarehousesForm.condition} " +
            "or warehouse_contact LIKE   #{selectWarehousesForm.condition} " +
            "or warehouse_address LIKE   #{selectWarehousesForm.condition} " +
            "or warehouse_tel LIKE   #{selectWarehousesForm.condition}) </if> " +
            "</script>")
    public IPage<Warehouses> selectAllWarehouses(Page<Integer> objectPage, @Param("selectWarehousesForm") SelectWarehousesForm selectWarehousesForm);

}